package com.heatup.apt.management.service.impl;

import com.heatup.apt.common.dao.TSysCityMapper;
import com.heatup.apt.common.dao.TSysDistriceMapper;
import com.heatup.apt.common.dao.TSysProvinceMapper;
import com.heatup.apt.model.*;
import com.heatup.apt.management.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by b3st9u on 16/9/19.
 */
@Service
public class AddressServiceImpl implements AddressService {
    @Autowired
    TSysProvinceMapper tSysProvinceMapper;
    @Autowired
    TSysCityMapper tSysCityMapper;
    @Autowired
    TSysDistriceMapper tSysDistriceMapper;

    @Override
    public List<TSysProvince> queryAllProvince() {
        TSysProvinceExample tSysProvinceExample = new TSysProvinceExample();
        return tSysProvinceMapper.selectByExample(tSysProvinceExample);
    }

    @Override
    public List<TSysCity> queryCityByProvinceId(long provinceId) {
        TSysCityExample tSysCityExample = new TSysCityExample();
        tSysCityExample.or().andProvinceIdEqualTo(provinceId);
        return tSysCityMapper.selectByExample(tSysCityExample);
    }

    @Override
    public List<TSysDistrice> queryDistriceByCityId(long cityId) {
        TSysDistriceExample tSysDistriceExample = new TSysDistriceExample();
        tSysDistriceExample.or().andCityIdEqualTo(cityId);
        return tSysDistriceMapper.selectByExample(tSysDistriceExample);
    }
}
